//
//  DKAuthScuessAlertView.m
//  DanKU
//
//  Created by 吴斌 on 2023/10/29.
//

#import "DKAuthScuessAlertView.h"
@interface DKAuthScuessAlertView()
@property (nonatomic, weak)zhPopupController * dk_AuthStartAlertViewPop;
@property (nonatomic,strong)DKAuthScuessAlertView *dk_AuthScuessAlertView;
@property (nonatomic, copy)void(^SureScuessAuthAlertBlock)(void);
@end
@implementation DKAuthScuessAlertView
-(instancetype)init{
    if(self == [super init]){
        self.backgroundColor = UIColor.whiteColor;
        self.layer.cornerRadius = 50;
        self.clipsToBounds = YES;
        [self dk_addSubView];
    }
    return self;
}
- (void)dk_addSubView{
    UILabel *dk_AuthStartContentLab = [[UILabel alloc] init];
    dk_AuthStartContentLab.textColor = DK_Hex(@"#4566FF");
    dk_AuthStartContentLab.font = DK_FONT_Medium(17);
    dk_AuthStartContentLab.numberOfLines = 0;
    dk_AuthStartContentLab.text = @"Congratulations you have completed all the stepsThe most suitable loan product has been matched for you,and the pass rate is as high as 90%";
    dk_AuthStartContentLab.textAlignment = NSTextAlignmentCenter;
    [self addSubview:dk_AuthStartContentLab];
    [dk_AuthStartContentLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(@(DK_IsWidthScale(39)));
        make.left.equalTo(@(DK_IsWidthScale(7)));
        make.right.equalTo(@(-DK_IsWidthScale(7)));
    }];
    UIButton * dk_AuthStartBtn = [[UIButton alloc] init];
    [dk_AuthStartBtn setTitle:@"Apply now" forState:UIControlStateNormal];
    [dk_AuthStartBtn setTitleColor:DK_Hex(@"#FFFFFF") forState:UIControlStateNormal];
    dk_AuthStartBtn.titleLabel.font = DK_FONT_Semibold(16);
    [dk_AuthStartBtn setBackgroundColor:DK_Hex(@"#4566FF")];
    dk_AuthStartBtn.layer.cornerRadius = DK_IsWidthScale(25);
    dk_AuthStartBtn.clipsToBounds = YES;
    [dk_AuthStartBtn addTarget:self action:@selector(startAuth) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:dk_AuthStartBtn];
    [dk_AuthStartBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(DK_IsWidthScale(30)));
        make.right.equalTo(@(-DK_IsWidthScale(30)));
        make.height.equalTo(@(DK_IsWidthScale(50)));
        make.bottom.equalTo(@(-DK_IsWidthScale(40)));
    }];
}
- (void)startAuth{
    WeakSelf(self)
    if(weakSelf.SureScuessAuthAlertBlock){
        weakSelf.SureScuessAuthAlertBlock();
    }
    [_dk_AuthStartAlertViewPop dismiss];
}
- (void)goCancle{
    [_dk_AuthStartAlertViewPop dismiss];
}

+ (void)dk_ShowAuthScuessAlertView:(void(^)(void))complete{
    DKAuthScuessAlertView * dk_AuthScuessAlertView = [[DKAuthScuessAlertView alloc] init];
    zhPopupController * sureAuthScuessCtrl = [[zhPopupController alloc] initWithView:dk_AuthScuessAlertView size:CGSizeMake(DK_SCREEN_W - DK_IsWidthScale(60), DK_IsWidthScale(288))];
    dk_AuthScuessAlertView.SureScuessAuthAlertBlock = complete;
    sureAuthScuessCtrl.presentationStyle = zhPopupSlideStyleTransform;
    sureAuthScuessCtrl.layoutType = zhPopupLayoutTypeCenter;
    sureAuthScuessCtrl.presentationTransformScale = 0.56;
    sureAuthScuessCtrl.dismissonTransformScale = 0.56;
    sureAuthScuessCtrl.dismissOnMaskTouched = NO;
    dk_AuthScuessAlertView.dk_AuthStartAlertViewPop = sureAuthScuessCtrl;
    [sureAuthScuessCtrl showInView:((AppDelegate*)([UIApplication sharedApplication].delegate)).window completion:^{
    }];
}
@end
